<?php
    include '../../../controlador/php/conexion/Conexion.php';
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of DaoSolicitudComponentes
 *
 * @author maospina
 */
class DaoSolicitudComponentes {
    //put your code here
    
    private $Oid;
    private $OidSoliServicio;
    private $OidCategoria;
    private $OidComponente;
    
    function __construct($Oid, $OidSoliServicio, $OidCategoria, $OidComponente) {
        $this->Oid = $Oid;
        $this->OidSoliServicio = $OidSoliServicio;
        $this->OidCategoria = $OidCategoria;
        $this->OidComponente = $OidComponente;
    }
    
    function getOid() {
        return $this->Oid;
    }

    function getOidSoliServicio() {
        return $this->OidSoliServicio;
    }

    function getOidCategoria() {
        return $this->OidCategoria;
    }

    function getOidComponente() {
        return $this->OidComponente;
    }

    function setOid($Oid) {
        $this->Oid = $Oid;
    }

    function setOidSoliServicio($OidSoliServicio) {
        $this->OidSoliServicio = $OidSoliServicio;
    }

    function setOidCategoria($OidCategoria) {
        $this->OidCategoria = $OidCategoria;
    }

    function setOidComponente($OidComponente) {
        $this->OidComponente = $OidComponente;
    }

    
    function GuardarSolicitudComponentes($LstOidComponentes){
        
        $con = new Conexion();
        
        $i = 0;
        $tamaño = count($LstOidComponentes);
        
        while ($i < $tamaño){
            
            $insert = "insert into DnSolicitudComponente_New(OidSoliServicio,OidCategoria,OidComponente)values(".$this->OidSoliServicio.",".$this->OidCategoria.",".$LstOidComponentes[$i].")";
            $con->query($insert);            
            $i++;
            
        }
        
        
        
        $con->cerrarConexion();
        
    }
    
    function ConsultarSolicitudComponente(){
        
        $con = new Conexion();
        
        $select = "SELECT *
                   FROM DnSolicitudComponente_New
                   WHERE OidSoliServicio = ".$this->OidSoliServicio;
        $re = $con->query($select);
        
        while ($re2 = mssql_fetch_array($re)) {

            $lista[] = array_map(utf8_encode,$re2);
        }
        
        print_r(json_encode($lista));
        
        $con->cerrarConexion();
        
    }

    
}
